//
//  YMTestReportShareView.m
//  YMMedical
//
//  Created by y s on 2023/7/22.
//

#import "YMTestReportShareView.h"
#import "YMTestReportTopInforView.h"
#import "YMTestReportChartsView.h"


@interface YMTestReportShareView ()

@property (nonatomic, strong) YMTestReportTopInforView *vInfor;

@property (nonatomic, strong) YMTestReportChartsView *vCharts;

@end

@implementation YMTestReportShareView

- (instancetype)init{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark -- UI
- (void)setUI{
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, [SFitUtil fit:222+50+10+335]);
    self.backgroundColor = [SUIUtil colorOf:0xF5F5F5];
    [self addSubview:self.vInfor];
    [self addSubview:self.vCharts];
    
    [self.vInfor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
    }];
    [self.vCharts mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.equalTo(self.vInfor.mas_bottom).offset([SFitUtil fit:15]);
        make.height.mas_equalTo([SFitUtil fit:335]);
    }];
}
- (void)setDict:(NSDictionary *)dict{
    self.vInfor.dict = dict;
    _vInfor.lblName.text = [NSString stringWithFormat:@"%@***",KLanguage(@"test_fix")];
    _vInfor.lblYear.text = [NSString stringWithFormat:@"%@**",KLanguage(@"age_fix")];
    self.vCharts.dict = dict;
    
    NSString *warningMsg = [SDataUtil stringOf:dict[@"warningMsg"] valid:@""];
    if (warningMsg != nil && warningMsg.length > 0){
        CGFloat height = [SFitUtil sizeOf:self.vInfor.lblWarning width:SCREEN_WIDTH-[SFitUtil fit:60]].height;
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, [SFitUtil fit:176+116+15+15+335+16]+height);
    }else{
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, [SFitUtil fit:176+116+15+15+335]);
    }
    
}

#pragma mark -- setter and getter
- (YMTestReportTopInforView *)vInfor{
    if (_vInfor == nil){
        _vInfor = [[YMTestReportTopInforView alloc] init];
    }
    return _vInfor;
}
- (YMTestReportChartsView *)vCharts{
    if (_vCharts == nil){
        _vCharts = [[YMTestReportChartsView alloc] init];
    }
    return _vCharts;
}


@end
